package com.evon.yardmanagement.transformer;

import com.evon.yardmanagement.model.ParkingSlot;
import com.evon.yardmanagement.model.Section;
import com.evon.yardmanagement.ui.dto.ParkingSlotDTO;
import com.evon.yardmanagement.ui.dto.SectionDTO;

public class ParkingSlotTransfer {
	
	static BaseTransformer<ParkingSlot, ParkingSlotDTO> transformer = new BaseTransformer<ParkingSlot, ParkingSlotDTO>(
			ParkingSlot.class, ParkingSlotDTO.class);

	public static ParkingSlot transform(ParkingSlotDTO psDTO){
		ParkingSlot ps = new ParkingSlot();
		
		//ps.setSection(psDTO.getSection());
		ps.setName(psDTO.getSlotName());
		ps.setNumber(psDTO.getSlotNumber());
		ps.setPriority(psDTO.getPriority());
		ps.setOccupied(psDTO.getOccupied()?1:0);
		
		return ps;
	}
	
	public static ParkingSlotDTO transformToModel(ParkingSlot ps){
		ParkingSlotDTO psDTO = new ParkingSlotDTO();
		
		//psDTO.setSection(ps.getSection());
		psDTO.setSlotName(ps.getName());
		psDTO.setSlotNumber(ps.getNumber());
		psDTO.setPriority(ps.getPriority());
		psDTO.setOccupied(ps.getOccupied()==1?true:false);
		
		return psDTO;
	}
	
	public static ParkingSlotDTO transformToDTO(ParkingSlot ps) {
		return transformer.transformToDTO(ps);
	}
	
	public static ParkingSlot transformToModel(ParkingSlotDTO psDTO) {
		return transformer.transformToModel(psDTO);
	}
}
